﻿<UserControl x:Class="TypeSuggestor"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:res="clr-namespace:Caps.Console.My.Resources"
    xmlns:my="clr-namespace:Caps.Console"
    xmlns:toolkit="clr-namespace:System.Windows.Controls;assembly=PresentationFramework"
    xmlns:sys="clr-namespace:System;assembly=mscorlib"
    BorderThickness="0">
    <UserControl.Resources>
        <my:ObjectImageConverter x:Key="ObjectImageConverter"/>
        <my:GetCapsOfConverter x:Key="GetCapsOfConverter"/>
    </UserControl.Resources>
    <Grid Name="grMain" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>        
        <Grid.RowDefinitions>
            <RowDefinition Height="auto"/>
            <RowDefinition Height="auto"/>
            <RowDefinition Height="auto"/>
            <RowDefinition Height="auto"/>
            <RowDefinition Height="auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        <Label Content="{x:Static res:Resources.lbl_SuggExTypes}" FontWeight="Bold" Grid.Row="0" Grid.Column="0" HorizontalAlignment="Left" />
        <Label Content="{x:Static res:Resources.lbl_NoSuggestions}" Grid.Row="1" Grid.Column="0" Name="lblNoExTypes" HorizontalAlignment="Left"  />
        <Label Grid.Row="2" Grid.Column="0" Name="lblExError" Visibility="Collapsed" Content="{x:Static Member=res:Resources.err_ErrorData}" HorizontalAlignment="Left"/>
        <ListBox Grid.Row="1" Grid.Column="0" Visibility="Collapsed" Name="lstExTypes" HorizontalAlignment="Stretch" SelectionMode="Single">
            <ListBox.ItemsPanel>
                <ItemsPanelTemplate>
                    <WrapPanel Orientation="Horizontal" ScrollViewer.HorizontalScrollBarVisibility="Hidden" ScrollViewer.VerticalScrollBarVisibility="Auto" IsItemsHost="True"/>
                </ItemsPanelTemplate>
            </ListBox.ItemsPanel>
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <Grid MaxWidth="40" Width="auto" Height="64" ToolTipService.ShowDuration="{x:Static sys:Int32.MaxValue}" MouseDown="ExType_MouseDown">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*"/>
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="32"/>
                            <RowDefinition Height="*"/>
                        </Grid.RowDefinitions>
                        <Image Source="{Binding CapType, Converter={StaticResource ObjectImageConverter}, Mode=OneWay}" MaxWidth="32" MaxHeight="32" Grid.Column="0" Grid.Row="0"/>
                        <TextBlock Grid.Column="0" Grid.Row="1" Text="{Binding TypeName, Mode=OneWay}" TextAlignment="Center" HorizontalAlignment="Stretch" VerticalAlignment="Top"
                                  MaxWidth="32" FontSize="8" TextWrapping="Wrap"/>
                        <Grid.ToolTip>
                            <Grid Height="auto" Width="auto">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="auto"/>
                                    <ColumnDefinition Width="auto"/>
                                    <ColumnDefinition Width="auto"/>
                                    <ColumnDefinition Width="auto"/>
                                    <ColumnDefinition Width="auto"/>
                                    <ColumnDefinition Width="*"/>
                                </Grid.ColumnDefinitions>
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="auto"/><RowDefinition Height="auto"/><RowDefinition Height="auto"/><RowDefinition Height="auto"/><RowDefinition Height="auto"/><RowDefinition Height="auto"/><RowDefinition Height="auto"/>
                                </Grid.RowDefinitions>
                                
                                <TextBlock Text="{Binding TypeName, Mode=OneWay}" HorizontalAlignment="Left" TextAlignment="Left" Grid.Column="0" Grid.Row="0" Height="auto" Grid.ColumnSpan="6" FontSize="14" FontWeight="Bold"/>
                                
                                <TextBlock Text="{Binding Description, Mode=OneWay}" HorizontalAlignment="Left" TextAlignment="Left" Grid.Column="0" Grid.Row="1" Height="auto"/>
                                
                                <TextBlock Grid.Column="0" Grid.Row="2" Text="{Binding Shape.Size1Name}" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,0,3,0"/>
                                <TextBlock Grid.Column="1" Grid.Row="2" Text="{Binding Size, Mode=OneWay}" VerticalAlignment="Center"/>
                                
                                <TextBlock Grid.Column="0" Grid.Row="3" Text="{Binding Shape.Size2Name}" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,0,3,0"/>
                                <TextBlock Grid.Column="1" Grid.Row="3" Text="{Binding Size2, Mode=OneWay}" VerticalAlignment="Center"/>
                                
                                <Label Grid.Column="0" Grid.Row="4" Content="{x:Static res:Resources.lbl_Height}" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,0,3,0"/>
                                <TextBlock Grid.Column="1" Grid.Row="4" Text="{Binding Height, Mode=OneWay}" VerticalAlignment="Center"/>
                                
                                <Label Grid.Column="3" Grid.Row="2" Content="{x:Static res:Resources.lbl_MainType}" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,0,3,0"/>
                                <Image Grid.Column="4" Grid.Row="2" Source="{Binding MainType, Converter={StaticResource ObjectImageConverter}, Mode=OneWay}" MaxHeight="16" MaxWidth="16" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                                <TextBlock Grid.Column="5" Grid.Row="2" Text="{Binding MainType.TypeName, Mode=OneWay}" VerticalAlignment="Center"/>
                                
                                <Label Grid.Column="3" Grid.Row="3" Content="{x:Static res:Resources.lbl_Shape}" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,0,3,0"/>
                                <Image Grid.Column="4" Grid.Row="3" Source="{Binding Shape, Converter={StaticResource ObjectImageConverter}, Mode=OneWay}" MaxHeight="16" MaxWidth="16" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                                <TextBlock Grid.Column="5" Grid.Row="3" Text="{Binding Shape.Name}" VerticalAlignment="Center"/>
                                
                                <Label Grid.Column="3" Grid.Row="4" Content="{x:Static res:Resources.lbl_Material}" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,0,3,0"/>
                                <TextBlock Grid.Column="4" Grid.ColumnSpan="2" Grid.Row="4" Text="{Binding Material.Name, Mode=OneWay}" VerticalAlignment="Center"/>
                                
                                <Label Grid.Column="3" Grid.Row="5" Content="{x:Static res:Resources.lbl_Target}" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,0,3,0"/>
                                <TextBlock Grid.Column="4" Grid.ColumnSpan="2" Grid.Row="5" Text="{Binding Target.Name, Mode=OneWay}" VerticalAlignment="Center"/>
                                
                                <ItemsControl  Style="{StaticResource ToolTipImageList}" Grid.Column="0" Grid.Row="6" Grid.ColumnSpan="6" ItemsSource="{Binding Type, Converter={StaticResource GetCapsOfConverter}, ConverterParameter=6}"/>
                            </Grid>
                        </Grid.ToolTip>
                    </Grid>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>
        <Label Content="{x:Static res:Resources.lbl_SuggNewTypes}" FontWeight="Bold" Grid.Row="3" Grid.Column="0" HorizontalAlignment="Left" />
        <Label Content="{x:Static res:Resources.lbl_NoSuggestions}" Grid.Row="4" Grid.Column="0" Name="lblNoNewTypes" HorizontalAlignment="Left" />
        <Label Grid.Row="4" Grid.Column="5" Name="lblNewError" Visibility="Collapsed" Content="{x:Static Member=res:Resources.err_ErrorData}" HorizontalAlignment="Left"/>
        <toolkit:DataGrid Grid.Row="5" Grid.Column="0" Visibility="Collapsed" Name="dgNewTypes" IsReadOnly="True" AutoGenerateColumns="False" HorizontalAlignment="Stretch" SelectionMode="Single">
            <toolkit:DataGrid.Resources>
               <ItemsControl x:Key="RowToolTip"  Style="{StaticResource ToolTipImageListEx}" ItemsSource="{Binding Caps}"/>
                <ContextMenu x:Key="RowContextMenu">
                    <MenuItem Header="{x:Static res:Resources.mni_CreateType}" Click="mniCreateType_Click"/>
                </ContextMenu>
            </toolkit:DataGrid.Resources>
                <toolkit:DataGrid.Columns>
                <toolkit:DataGridTemplateColumn Header="{x:Static res:Resources.coh_MainType}" >
                    <toolkit:DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <StackPanel Orientation="Horizontal">
                                <Image Width="16" Height="16" Source="{Binding MainType, Converter={StaticResource ObjectImageConverter}, Mode=OneWay}"/>
                                <TextBlock Text="{Binding MainType.TypeName, Mode=OneWay}"/>
                            </StackPanel>
                        </DataTemplate>
                    </toolkit:DataGridTemplateColumn.CellTemplate>
                </toolkit:DataGridTemplateColumn>
                <toolkit:DataGridTemplateColumn  Header="{x:Static res:Resources.coh_Shape}">
                    <toolkit:DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <StackPanel Orientation="Horizontal">
                                <Image Width="16" Height="16" Source="{Binding Shape, Converter={StaticResource ObjectImageConverter}, Mode=OneWay}"/>
                                <TextBlock Text="{Binding Shape.Name, Mode=OneWay}"/>
                            </StackPanel>
                        </DataTemplate>
                    </toolkit:DataGridTemplateColumn.CellTemplate>
                </toolkit:DataGridTemplateColumn>
                <toolkit:DataGridTextColumn Binding="{Binding Size, Mode=OneWay}" Header="{x:Static res:Resources.coh_Size1}"/>
                <toolkit:DataGridTextColumn Binding="{Binding Size2, Mode=OneWay}" Header="{x:Static res:Resources.coh_Size2}" />
                <toolkit:DataGridTextColumn Binding="{Binding Height, Mode=OneWay}" Header="{x:Static res:Resources.coh_Height}"/>
                <toolkit:DataGridTextColumn Binding="{Binding Material.Name, Mode=OneWay}" Header="{x:Static res:Resources.coh_Material}"/>
                <toolkit:DataGridTextColumn Binding="{Binding Target.Name, Mode=OneWay}" Header="{x:Static res:Resources.coh_Target}"/>
            </toolkit:DataGrid.Columns>
            <toolkit:DataGrid.RowStyle>
                <Style TargetType="{x:Type toolkit:DataGridRow}">
                    <Setter Property="ToolTip" Value="{StaticResource RowToolTip}" />
                    <Setter Property="ToolTipService.ShowDuration" Value="{x:Static sys:Int32.MaxValue}"/>
                    <Setter Property="ContextMenu" Value="{StaticResource RowContextMenu}"/>
                </Style>
            </toolkit:DataGrid.RowStyle>
        </toolkit:DataGrid>
    </Grid>
</UserControl>
